﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace UtopianGame.graphics.menu
{
    class MenuButton : GraphicalObject
    {
        public MenuButton()
        {
        }

        public MenuButton(ContentManager cm)
        {
            init(cm);
        }

        protected override void init(ContentManager cm)
        {
            base.init(cm);
            spriteName = "button1";
            sprite = cm.Load<Texture2D>(spriteName);
            clickable = true;
            boundingBox = new Microsoft.Xna.Framework.Rectangle(0, 0, sprite.Width, sprite.Height);
        }

        public override void clicked(MouseState m)
        {
            base.clicked(m);

            //If the mouse's coordinates are within the sprite's bounding box, then activate the menu button's code.
            if (m.X >= boundingBox.X && m.X < (boundingBox.X + boundingBox.Width) && m.Y >= boundingBox.Y && m.Y < (boundingBox.Y + boundingBox.Height))
            {
                executeFunction();
            }
            
        }

        protected virtual void executeFunction()
        {
            boundingBox.X += 5; //DEBUG. This should be removed later in development.
        }
    }
}
